//首页侧边栏动画
let fadeModel = function fade() {
    //二级菜单点击事件
    function checkTwoRank() {
        let menus = document.querySelectorAll(".content");
        for (let i = 0; i < menus.length; i++) {
            menus[i].onclick = function () {
                let ul = menus[i].parentNode.querySelector("ul");
                if (ul) {
                    if (ul.style.height === "0px" || ul.style.height === "") {
                        let length = ul.getElementsByTagName("li").length;
                        let height = (length) * 50;
                        ul.style.height = height + "px";
                    } else {
                        ul.style.height = "0";
                    }
                }
            }
        }
    }

    function twoMenuShow() {
        if (document.querySelector(".selectTwoRank")) {
            let node = document.querySelector(".selectTwoRank");
            let ulPareNode = node.parentNode.parentNode;
            ulPareNode.style.height = ulPareNode.getElementsByTagName("li").length * 50 + "px";
        } else {
            let selectNum = parseURL(window.location.href).params.select;
            if (!document.querySelector(".examineList")) {
                return;
            }
            let ul = document.querySelector(".examineList");
            let aList = ul.querySelectorAll("a");
            ul.style.height = aList.length * 50 + "px";
            if (selectNum === "0") {
                aList[0].className = "left-item-height twoRank-a selectTwoRank";
            } else if (selectNum === "-1") {
                aList[1].className = "left-item-height twoRank-a selectTwoRank";
            } else if (selectNum === "1") {
                aList[2].className = "left-item-height twoRank-a selectTwoRank";
            }
        }
    }

    function checkFade() {
        getClass("nav-left")[0].onclick = function () {
            if (document.getElementsByTagName("body")[0].clientWidth > 773) {
                let left = getClass("left")[0];
                let right = getClass("right")[0];
                if (left.style.left === "-220px") {
                    left.style.left = "0";
                    right.style.paddingLeft = "220px";
                } else {
                    left.style.left = "-220px";
                    right.style.paddingLeft = "0";
                }
            }
            else {
                let leftModel = getClass("left-model")[0];
                if (leftModel.style.left === "-308px" || leftModel.style.left === "") {
                    leftModel.style.left = "0";
                } else {
                    leftModel.style.left = "-308px";
                }
            }
        };
        getClass("left-model-header")[0].onclick = function () {
            let leftModel = getClass("left-model")[0];
            if (leftModel.style.left === "-308px") {
                leftModel.style.left = "0";
            } else {
                leftModel.style.left = "-308px"
            }
        }
    }

    //修复右边内容页到达773px时paddingLeft等于220px
    function changeRightPadding() {
        let left = getClass("left")[0];
        let right = getClass("right")[0];
        if (document.getElementsByTagName("body")[0].clientWidth < 773) {
            right.style.paddingLeft = "0";
            left.style.left = "-220px";
        } else {
            if (right.style.paddingLeft === "0px") {
                left.style.left = "-220px";
            }
        }
    }

    function startMenuShow() {
        let left = getClass("left")[0];
        let right = getClass("right")[0];
        if (document.getElementsByTagName("body")[0].clientWidth > 773) {
            left.style.left = "0";
            right.style.paddingLeft = "220px";
        }
    }

    return {
        checkTwoRank: checkTwoRank,
        twoMenuShow: twoMenuShow,
        checkFade: checkFade,
        startMenuShow: startMenuShow,
        changeRightPadding: changeRightPadding
    }
};